/**
 * 文件名:HttpUtils.java
 *
 * 功能: http相关工具类
 *
 * 创建日期:2017年1月12日
 *
 * 变更记录:
 *
 * 作者:陈保毕
 *
 */
package com.hpjz.common.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

public class HttpUtils {

	private HttpUtils(){
		
	}
	 
	/**
	 * 获取HttpServletRequest请求
	 * @return
	 */
	public static HttpServletRequest getHttpServletRequest(){
		ServletRequestAttributes requestAttr = 
				 (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
		HttpServletRequest request = requestAttr.getRequest();
	    return request;
	}
	
	
	 /**
	  * 获取HttpServletResponse请求
	  * @return
	  */
    public static HttpServletResponse getHttpServletResponse(){
    	ServletRequestAttributes responseAttr = 
    			(ServletRequestAttributes)RequestContextHolder.currentRequestAttributes();
    	HttpServletResponse response = responseAttr.getResponse();
    	return response;
    }
	
}
